
#ifndef I2C_BUS_H
#define I2C_BUS_H

#include "hal_drv.h"

/*! @brief The direction of master and slave transfers. */
typedef enum _i2c_direction
{
    kI2C_Write = 0x0U, /*!< Master transmits to the slave. */
    kI2C_Read  = 0x1U, /*!< Master receives from the slave. */
} i2c_direction_t;

typedef struct _i2c_master_transfer
{
    uint32_t flags;            /*!< A transfer flag which controls the transfer. */
    uint8_t slaveAddress;      /*!< 7-bit slave address. */
    i2c_direction_t direction; /*!< A transfer direction, read or write. */
    uint32_t subaddress;       /*!< A sub address. Transferred MSB first. */
    uint8_t subaddressSize;    /*!< A size of the command buffer. */
    uint8_t *volatile data;    /*!< A transfer buffer. */
    volatile uint32_t dataSize;  /*!< A transfer size. */
} i2c_master_transfer_t;

typedef struct
{
    int32_t (*transer)(void *handle, i2c_master_transfer_t *transfer);
}i2c_general_bus_t;

#endif
